Skip to content

Conversation

williasc
Copy link
Member

The search used to look for the whole text as one phrase, so "noir pinot" found far fewer wines than "pinot noir", and "creek zinfandel" found nothing.

The backend now splits the search text into words and requires each word to be somewhere in the wine's name, winery, region or grapes. The order of the words no longer matters.

Changes

  • backend/src/wine-query.ts: one search condition per word instead of one for the whole text. A search uses at most 10 words, so a single request cannot make the query very large.
  • backend/src/wine-query.test.ts: tests for word order, a repeated word, a search with only spaces, and the 10-word limit.
  • README.md: the feature table describes the new behaviour, and the known issue about "noir pinot" is removed.

Testing

npm run check passes.

I loaded the Full dataset's 100 646 wines into a local database and timed the queries the backend sends:

Search Hits Time
pinot noir 10 503 10 ms
noir pinot 10 503 9 ms
deadly zinfandel 2 under 1 ms
de 34 202 32 ms

The slowest searches are those with only one or two letters, such as "de". They cannot use the search index, which was also the case before this change.

These times are from a laptop, not the VM. The VM is slower, so the issue's goal of under 100 ms on the VM is likely met but not measured there.

Closes #111

@williasc williasc requested a review from a team as a code owner November 25, 2026 14:34
@williasc williasc linked an issue Nov 25, 2026 that may be closed by this pull request
3 tasks
Copy link
Member

@siverne siverne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, approving! Each word is a parameter and escaped, whitespace is collapsed before splitting, and the same condition is used for the hits, the count and the filter counts. The 10-word limit is a nice touch.

Not blocking: after the next deploy it would be good to time "pinot noir" on the VM, since the numbers are from a laptop.

@siverne siverne merged commit 13f9888 into main Nov 25, 2026
@siverne siverne deleted the 111-search-should-match-words-in-any-order branch November 25, 2026 15:04
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search should match words in any order
2 participants